/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package IRS.Domains;

import com.google.code.bing.search.schema.web.WebResult;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author lin
 */
public class LocalResult {

	private String title;
	private String description;
	private Date datetime;
	private String url;

	private boolean relevant = false;
	private Map<String,Integer> terms = new HashMap<String,Integer>();

	public LocalResult(WebResult result, boolean relevant){
		this.title = result.getTitle();
		this.description = result.getDescription();
		this.datetime = result.getDateTime();
		this.url = result.getUrl();
		this.relevant = relevant;
		
		this.parse(result);
	}

	private void parse(WebResult result) {
		String[] tmp_terms = description.split("[^a-z^A-Z^0-9]+");
		for(int i = 0; i<tmp_terms.length; i++){
			if(terms.containsKey(tmp_terms[i]))
				terms.put(tmp_terms[i], terms.get(tmp_terms[i])+1);
			else
				terms.put(tmp_terms[i], 1);
		}
	}

	public String getTitle() {
		return this.title;
	}

	public String getDescription() {
		return this.description;
	}

	public Map<String, Integer> getTerms() {
		return this.terms;
	}

	public Date getDateTime() {
		return this.datetime;
	}

	public String getUrl() {
		return this.url;
	}

	public boolean getRelevant() {
		return this.relevant;
	}

	public Object getTermsVector() {
		throw new UnsupportedOperationException("Not yet implemented");
	}
}
